//
//  xxServer_Use_Data.m
//  MacStockApp
//
//  Created by Andy MacPro on 12/11/4.
//
//

#import "xxServer_Use_Data.h"
#import "xxServer_Valid.h"
#import "GBall.h"
#import "xxBuild_dic_gc.h"
@implementation xxServer_Use_Data

//輸入google代碼轉得出伺服器資料取得流程
-(id)init{
    if ( (self = [super init]) ) {
      
    }
    return self;
}


+(NSMutableDictionary *)input_googleCode_get_ServerUseData:(NSString *)googlecode{
   
    
    
    //代碼
    NSString *yahooCode=@"";
    NSString *bloombergCode=@"";
    NSString *xxtradexxCode=@"";
    
    //1.取出google code中的交易所代碼 與股票代碼
    NSString *google_exchange;
    NSString *google_symbol; //不含交易所碼或國家碼
    {
        NSArray *ga=[googlecode componentsSeparatedByString:@":"];
        if ([ga count]==2) {
            
            google_symbol=[ga objectAtIndex:1];
            google_exchange=[ga objectAtIndex:0];
            
            //NSLog(@"google_symbol=%@ google_exchange=%@",google_symbol,google_exchange );
            
        }
        else {
            //
            NSLog(@"google輸入代碼有誤");
            return nil;
        }
        
        
        
    }
    
    //2.依照不同交易所進行轉換
    {
        
        //美洲區
        //美國交易所 股票
        if ([google_exchange isEqualToString:@"NASDAQ"] ||
            [google_exchange isEqualToString:@"NYSE"] ||
            [google_exchange isEqualToString:@"NYSEAMEX"]||
            [google_exchange isEqualToString:@"NYSEARCA"]||
            [google_exchange isEqualToString:@"OTC"]||
            [google_exchange isEqualToString:@"PINK"]) {
           
       
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    //代碼如果內部有. 就要轉換為-
                    yahooCode=[google_symbol stringByReplacingOccurrencesOfString:@"." withString: @"-" ];
                    bloombergCode=[NSString stringWithFormat:@"%@:US",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xUS",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                    
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                    
                }
                
                //bloomberg 有效性
                {
                    
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                        
                    }
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }
            }
            
            //2.建立字典
             return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
            
        }
        //美國交易所 指數INDEXDJX INDEXNASDAQ
        else if ([google_exchange isEqualToString:@"INDEXDJX"]  || [google_exchange isEqualToString:@"INDEXNASDAQ"]){
            
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                     
                  
                    yahooCode=[NSString stringWithFormat:@"^%@",google_symbol];
                   
                    bloombergCode=[NSString stringWithFormat:@"%@:IN",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xIN",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                    
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                    
                }
                
                //bloomberg 有效性
                {
                    
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                        
                    }
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            

        }
        //加拿大 TSE
        else if ([google_exchange isEqualToString:@"TSE"]) {
            
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"TO"];

                    bloombergCode=[NSString stringWithFormat:@"%@:CN",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xCN",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                    
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                    
                }
                
                //bloomberg 有效性
                {
                    
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                        
                    }
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
        }
        //加拿大 CVE
        else if ([google_exchange isEqualToString:@"CVE"]) {
           
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"V"];
                    
                    bloombergCode=[NSString stringWithFormat:@"%@:CN",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xCN",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                    
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                    
                }
                
                //bloomberg 有效性
                {
                    
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                        
                    }
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
        }
        
        //歐洲區
        //歐洲區指數 INDEXEURO 理論 yahoo裡面沒有此相對應資料
        //倫敦 LON
        else if ([google_exchange isEqualToString:@"LON"]) {
            
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",[google_symbol stringByReplacingOccurrencesOfString:@"." withString: @"-" ],@"L"];
                    
                    bloombergCode=[NSString stringWithFormat:@"%@:LN",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xLN",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                    
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                    
                }
                
                //bloomberg 有效性
                {
                    
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                        
                    }
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
            
        }
        //德國 FRA
        else if ([google_exchange isEqualToString:@"FRA"] ) {
            
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",[google_symbol stringByReplacingOccurrencesOfString:@"." withString: @"-" ],@"DE"];
                    
                    bloombergCode=[NSString stringWithFormat:@"%@:GR",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xGR",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                    
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                    
                }
                
                //bloomberg 有效性
                {
                    
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                        
                    }
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];            
            
            
            
        }
        //義大利 BIT
        else if ([google_exchange isEqualToString:@"BIT"] ) {
            
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",[google_symbol stringByReplacingOccurrencesOfString:@"." withString: @"-" ],@"MI"];
                    
                    bloombergCode=[NSString stringWithFormat:@"%@:EB",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xEB",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                    
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                    
                }
                
                //bloomberg 有效性
                {
                    
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                        
                    }
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];            
            
            
            
        }
         
        
        //亞洲區
        //台灣指數 股票
        else if ([google_exchange isEqualToString:@"TPE"]) {
            
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"TW"]; //先用上市代碼
                    bloombergCode=[NSString stringWithFormat:@"%@:TT",google_symbol];                   
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xTT",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                  
                    if (google_valid==NO) {
                        
                        //如果google只有台灣上市資料 所以如果google資料存在表示就是上市股票或是指數
                                             
                        //改成上櫃代碼
                        yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"TWO"];
                    }
                    
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                     
                }
                
                //bloomberg 有效性
                {
                                            
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {                        
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                                         
                    }
                    
                
                }                 
               
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }                 
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];            
        }
        //香港指數
        else if ([google_exchange isEqualToString:@"INDEXHANGSENG"]) {
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"HK"]; //先用上市代碼
                    bloombergCode=[NSString stringWithFormat:@"%@:HK",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xHK",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=YES;                                         
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=NO;
                    
                }
                
                //bloomberg 有效性
                {
                    
                    
                        
                    
                    bloomberg_valid=NO;
                   
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                     
                        
                    
                    xxtradexx_valid=NO;
                        
                    
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
        }
        //香港股票
        else if ([google_exchange isEqualToString:@"HKG"]) {
            
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"HK"];  
                    bloombergCode=[NSString stringWithFormat:@"%@:HK",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xHK",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                                       
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                    
                }
                
                //bloomberg 有效性
                {
                    
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                        
                    }
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
        }
        //東京指數
        else if ([google_exchange isEqualToString:@"INDEXNIKKEI"]) {
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"JP"]; //先用上市代碼
                    bloombergCode=[NSString stringWithFormat:@"%@:JP",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xJP",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=YES;
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=NO;
                    
                }
                
                //bloomberg 有效性
                {
                    
                    
                    
                    
                    bloomberg_valid=NO;
                    
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    
                    
                    
                    xxtradexx_valid=NO;
                    
                    
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
        }
        //東京股票
        else if ([google_exchange isEqualToString:@"TYO"]) {
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"JP"]; //先用上市代碼
                    bloombergCode=[NSString stringWithFormat:@"%@:JP",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xJP",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=YES;
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=NO;
                    
                }
                
                //bloomberg 有效性
                {
                    
                    
                    
                    
                    bloomberg_valid=NO;
                    
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    
                    
                    
                    xxtradexx_valid=NO;
                    
                    
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
        }
        //上海指數 股票
        else if ([google_exchange isEqualToString:@"SHA"]) {
            
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"SS"];
                    bloombergCode=[NSString stringWithFormat:@"%@:CH",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xCH",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                    
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                    
                }
                
                //bloomberg 有效性
                {
                    
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                        
                    }
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
        }
        //深證指數 股票
        else if ([google_exchange isEqualToString:@"SHE"]) {
            
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"SZ"];
                    bloombergCode=[NSString stringWithFormat:@"%@:CH",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xCH",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                    
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                    
                }
                
                //bloomberg 有效性
                {
                    
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                        
                    }
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
        }
        //印度指數
        else if ([google_exchange isEqualToString:@"INDEXBOM"]) {
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"BO"]; //先用上市代碼
                    bloombergCode=[NSString stringWithFormat:@"%@:IN",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xIN",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=YES;
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=NO;
                    
                }
                
                //bloomberg 有效性
                {
                    
                    
                    
                    
                    bloomberg_valid=NO;
                    
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    
                    
                    
                    xxtradexx_valid=NO;
                    
                    
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
        }
        //印度 股票 印度國家證券交易所
        else if ([google_exchange isEqualToString:@"NSE"]) {
            
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"NS"];
                    bloombergCode=[NSString stringWithFormat:@"%@:IN",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xIN",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                    
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                    
                    if (yahoo_valid==NO) {
                        
                        yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"BO"];
                        
                        yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                        
                    }
                    
                    
                    
                }
                
                //bloomberg 有效性
                {
                    
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                        
                    }
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
        }
        //印度 股票 孟買證券交易所
        else if ([google_exchange isEqualToString:@"BOM"]) {
            
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"NS"];
                    bloombergCode=[NSString stringWithFormat:@"%@:IN",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xIN",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                    
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                    
                }
                
                //bloomberg 有效性
                {
                    
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                        
                    }
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
        }
        
        //南太平洋區
        //澳洲指數
        else if ([google_exchange isEqualToString:@"INDEXASX"]) {
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"AX"]; //先用上市代碼
                    bloombergCode=[NSString stringWithFormat:@"%@:AX",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xAX",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=YES;
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=NO;
                    
                }
                
                //bloomberg 有效性
                {
                    
                    
                    
                    
                    bloomberg_valid=NO;
                    
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    
                    
                    
                    xxtradexx_valid=NO;
                    
                    
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
        }
        //澳洲 股票
        else if ([google_exchange isEqualToString:@"ASX"]) {
            
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"AX"];
                    bloombergCode=[NSString stringWithFormat:@"%@:AU",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xAU",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                    
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                    
                }
                
                //bloomberg 有效性
                {
                    
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                        
                    }
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
        }
        //紐西蘭指數 股票
        else if ([google_exchange isEqualToString:@"NZE"]) {
            
            BOOL google_valid;
            BOOL yahoo_valid;
            BOOL bloomberg_valid=NO;
            BOOL xxtradexx_valid=NO;
            //1.代碼分析與有效性判斷
            {
                //代碼
                {
                    yahooCode=[NSString stringWithFormat:@"%@.%@",google_symbol,@"NZ"];
                    bloombergCode=[NSString stringWithFormat:@"%@:NZ",google_symbol];
                    xxtradexxCode=[NSString stringWithFormat:@"%@:xNZ",google_symbol];
                }
                
                //b.google 代碼有效性與 是否修改yahoo代碼
                {
                    
                    google_valid=[xxServer_Valid is_google_code_valid:googlecode];
                    
                    
                }
                
                //yahoo 有效性
                {
                    yahoo_valid=[xxServer_Valid is_yahoo_code_valid:yahooCode];
                    
                }
                
                //bloomberg 有效性
                {
                    
                    //當google 與yahoo都沒有資料時才去檢查bloomberg
                    if (google_valid==NO && yahoo_valid==NO) {
                        
                        bloomberg_valid=[xxServer_Valid is_bloomberg_code_valid:bloombergCode];
                        
                    }
                    
                    
                }
                
                //xxtradexx伺服器有效性
                {
                    if (google_valid==NO && yahoo_valid==NO && bloomberg_valid==NO) {
                        
                        xxtradexx_valid=[xxServer_Valid is_xxtradexx_code_valid:xxtradexxCode];
                        
                    }
                }
            }
            
            //2.建立字典
            return [xxBuild_dic_gc build_dic_gc:googlecode _yc:yahooCode _bc:bloombergCode _xc:xxtradexxCode _gv:google_valid _yv:yahoo_valid _bv:bloomberg_valid _xv:xxtradexx_valid ];
            
            
        }
                
        //完全無法判斷
        else{
            return nil;
        }
        
    }
    
    return nil;
    
    
}

@end
